package com.homework;

/*
1.请定义一个交通工具(Vehicle)的类其中有:
属性： 速度(speed)、 体积(size)等，
方法：移动(move())、设置速度(setSpeed(int speed))、加速 speedUp()、减速 speedDown()等。
最后在测试类 Vehicle 中的 main()中实例化一个交通工具对象并通过方法给它初始化 speed,size 的值并且通过打印出来。
另外调用加速、减速的方法对速度进行改变。
 */
class Vehicle {
    private int speed;
    private int size;

    public Vehicle() {
    }

    public Vehicle(int speed, int size) {
        this.speed = speed;
        this.size = size;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public void move() {
        System.out.println("移动");
    }

    public int speedUp(int speed) {
        return ++speed;
    }
    public int speedDown(int speed) {
        return --speed;
    }
}
public class JavaMethodHomework1 {
    public static void main(String[] args) {
        Vehicle vehicle = new Vehicle();
        vehicle.setSpeed(100);
        vehicle.setSize(100);
        System.out.println("速度" + vehicle.getSpeed());
        System.out.println("体积" + vehicle.getSize());
        int speedUp = vehicle.speedUp(vehicle.getSpeed());
        System.out.println("更改后的速度" + speedUp);
        int speedDown = vehicle.speedDown(vehicle.getSpeed());
        System.out.println("更改后的速度" + speedDown);
        vehicle.move();
    }
}
